const { DataTypes } = require('sequelize');
const sequelize = require('@shared/utils/database');

const Address = sequelize.define('Address', {
  id: {
    type: DataTypes.BIGINT,
    primaryKey: true,
    autoIncrement: true,
    comment: '地址ID'
  },
  user_id: {
    type: DataTypes.BIGINT,
    allowNull: false,
    comment: '用户ID'
  },
  receiver: {
    type: DataTypes.STRING(32),
    allowNull: false,
    comment: '收货人'
  },
  phone: {
    type: DataTypes.STRING(11),
    allowNull: false,
    comment: '联系电话'
  },
  province: {
    type: DataTypes.STRING(32),
    allowNull: false,
    comment: '省份'
  },
  city: {
    type: DataTypes.STRING(32),
    allowNull: false,
    comment: '城市'
  },
  district: {
    type: DataTypes.STRING(32),
    allowNull: false,
    comment: '区县'
  },
  detail: {
    type: DataTypes.STRING(128),
    allowNull: false,
    comment: '详细地址'
  },
  is_default: {
    type: DataTypes.TINYINT,
    allowNull: false,
    defaultValue: 0,
    comment: '是否默认：0-否 1-是'
  }
}, {
  tableName: 'address',
  timestamps: true,
  createdAt: 'create_time',
  updatedAt: 'update_time'
});

module.exports = Address; 